import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      component: () => import("../components/index/index"),
      children: [
        {
          path: '/',
          component: () => import("../components/index/first")
        },
        {
          path: "/book/detail",
          component: () => import("../components/book/bookDetail")
        },
        {
          path: "/chapter/list",
          component: () => import("../components/book/chapterList")
        },
        {
          path: "/chapter/read",
          component: () => import("../components/book/readBook")
        },
        {
          path: "/self",
          component: () => import("../components/self/self")
        },
        {
          path: "/book/query",
          component: ()=>import("../components/index/queryBook")
        },
        {
          path: "/user/collect",
          component: ()=>import("../components/self/collect")
        },
        {
          path: "/user/friend",
          component: ()=>import("../components/self/friend")
        },
        {
          path: "/user/message",
          component: ()=>import("../components/self/message")
        },
        {
          path: "/user/talk",
          component: ()=>import("../components/self/talk")
        },
        {
          path: "/advise",
          component: () => import("../components/system/advise")
        }
      ]
    },
    {
      path: "/login",
      component: () => import("../components/login/login")
    }
  ]
})
